package interview;


import java.util.Stack;

/**
 * Assert.assertEquals(convertToBase7(100), "202");
 * Assert.assertEquals(convertToBase7(-7),"-10");
 */
public class MainCode {



    public static void main(String[] args) {

        // 7 1
        // 8 11
        // 9 12
        // 10 13
        // 11 14
        // 12 15
        // 13 16
        // 14 20
        // 15 21
        MainCode mainCode = new MainCode();

        String convert = mainCode.convert(-7);
        System.out.println(convert);
    }


    private String convert(int num){
        StringBuffer stringBuffer = new StringBuffer(num < 0 ? "-" : "");
        Stack<String> s = new Stack();
        while (num > 0 ? num > 0 : num < 0){
            s.push(num % 7 + "");
            num = num /7;
        }
        while (!s.isEmpty()) {
            stringBuffer.append(Math.abs(Integer.valueOf(s.pop())));
        }
        return stringBuffer.toString();
    }

}
